<?php
declare(strict_types=1);
namespace Model;
// hook model_ws_use.php

use App\Model;
use Framework\Support\SqliteDb;

class WsModel extends Model
{
    // hook model_ws_public_start.php
    public string $table = 'ws';
    public SqliteDb $sqliteDb;

    // hook model_ws_public_end.php
    public function __construct()
    {
        parent::__construct();
        $this->sqliteDb = $_ENV['db_ws'];

    }

    /**
     * 插入
     */
    public function insert(array $val):int
    {
        // hook model_ws_insert_start.php
        // hook model_ws_insert_end.php
        return (int)$this->sqliteDb->insert($this->table, $val);
    }

    /**
     * 更新数据
     * @param array $cond
     * @param array $new
     */
    public function update(array $cond,array $new):bool|int
    {
        // hook model_ws_update_start.php
        // hook model_ws_update_end.php
        return !empty($cond) ? $this->sqliteDb->update($this->table, $cond, $new):false;
    }
    /**
     * 删除数据
     * @param array $cond
     */
    public function delete(array $cond):bool|int
    {
        // hook model_ws_delete_start.php
        // hook model_ws_delete_end.php
        return !empty($cond) ? $this->sqliteDb->delete($this->table, $cond):false;
    }

    /**
     * 查询数据
     */
    public function select(array $cond = [],array  $order = [],int $page = 0,int $limit = 0,array $select = [],string $key = '',string $group = ''):array
    {
        return $this->sqliteDb->find($this->table, $cond, $order, $page, $limit, $key, $select, $group);
    }
    // hook model_ws_start.php

    // hook model_ws_end.php
}

?>